package com.gery.tn.backend.service.ini;

import com.gery.tn.backend.model.Client;
import com.gery.tn.backend.service.ClientService;
import com.gery.tn.backend.service.DAOFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;



public final class IniClientService implements ClientService {
    
    private INIFile ini;

    public IniClientService() throws IOException {
        ini = new INIFile("C:/Users/Gery/Documents/NetBeansProjects/TiaNails/src/com/gery/tn/backend/service/ini/db.ini");
    }
    

    @Override
    public void saveClient(Client client) {
        
    }

    @Override
    public void deleteClient(long id) {
        ini.removeSection("");
        ini.save();
    }

    @Override
    public List<Client> getAllClients() {
        String[] clientNames = ini.getAllSectionNames();
        List<String> clients = new ArrayList<>();
        int clientNr = clientNames.length;
        for (int i=0; i<clientNr; i++) {
            clients.add(clientNames[i]);
        }
        return null;
    }

    @Override
    public Client getClient(long id) {
        Client tempClient = new Client();
//        tempClient.setName(client);
//        System.out.println(ini.getStringProperty(client, "tel"));
//        tempClient.setTel(ini.getStringProperty(client, "tel"));
//        tempClient.setEmail(ini.getStringProperty(client, "mail"));
//        //tempClient.setPoints(ini.getStringProperty(client, "points"));
//        tempClient.setWebID(ini.getStringProperty(client, "webid"));
//        tempClient.setFbID(ini.getStringProperty(client, "fbid"));
        //tempClient.setAppointments(DAOFactory.getInstance().getAppointmentService().getAppointmentList(client));
        return null;
    }

    @Override
    public List<Client> searchFor(String str) {
        //List<String> temp = getAllClients();
        List<Client> results = new ArrayList<>(10);
        int count = 0;
//        for (String curVal : temp) {
//            if (count == 10) return results;
//            if (curVal.toLowerCase().contains(str)) {
//                count++;
//                //Client client = new Client(curVal, ini.getStringProperty(curVal, "tel"), "", ini.getStringProperty(curVal, "points"), "", null);
//                //results.add(client);
//            }
//        }
        return null;
    }
    
}
